package com.iminutes.service.impl;

import com.iminutes.dao.UserDao;
import com.iminutes.service.UserService;

/**
 * DI注入之set注入
 * 1.定义引用类型变量UserDao userDao
 * 2.实现set方法
 * 3.xml文件中进行注入声明
 *
 *
 * 非引用类型
 * 1.定义非引用类型属性
 * 2.实现set方法
 * 3.xml中设置prop属性
 */
public class UserServiceImpl implements UserService {
    //报错Exception in thread "main" java.lang.NullPointerException
    private UserDao userDao;
    private String username;
    private int age;

    public void setUsername(String username) {
        this.username = username;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public void save() {
        userDao.save();
        System.out.println("add...service..."+age+username);
    }
}
